﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DcsGauges.Gui.Gauges.Interfaces;
using DcsGauges.Gui.Gauges.Panels;
using DcsGauges.DataStructures;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using DcsGauges.Shared.Exceptions;

namespace DcsGauges.Gui.Views.Concrete
{
    class EnvironmentOxygenTestView : View, IMultiTriggerGauge
    {
        #region Fields & Properties

        private EnvironmentPanel                    environment                     = null;

        #endregion


        #region Constructors

        public EnvironmentOxygenTestView() 
        {
            this.environment                        = new EnvironmentPanel(this, new URect(new ULoc(0.0f, 0.2f), new USize(1.0f, 0.8f)));
        }

        #endregion


        #region Interface Implementation

        public event EventHandler<TriggerValueEventArgs>  TriggerEvent;

        public Shared.DataStructures.DcsProperty[] Properties
        {
            get { return this.environment.Properties; }
        }

        public void SetValue(Shared.DataStructures.DcsProperty property, float value)
        {
            if (this.environment.Properties.Contains(property))
            {
                this.environment.SetValue(property, value);
            }
            else
            {
                throw new DcsArgumentException(string.Format(Localization.ExcPropertyInvalidForGauge2A, property.Name, typeof(ElectricalAndOxygenRegulatorView)));
            }
        }

        public float GetValue(Shared.DataStructures.DcsProperty property)
        {
            if (this.environment.Properties.Contains(property))
            {
                float value = this.environment.GetValue(property);
                return value;
            }
            else
            {
                throw new DcsArgumentException(string.Format(Localization.ExcPropertyInvalidForGauge2A, property.Name, typeof(ElectricalAndOxygenRegulatorView)));
            }
        }

        #endregion


        #region Overrides

        public override void Render(SpriteBatch spriteBatch, GraphicsDevice device, Rectangle parentRect, float globalZIndex)
        {
            this.environment.Render(spriteBatch, device, parentRect, globalZIndex);
        }


        #endregion
    }
}
